//
// Created by 刘洋 on 2024/2/4.
//

#ifndef FOC3_PID_H
#define FOC3_PID_H
typedef struct
{
    float P;
    float I;
    float D;
    float target;
    float current_error;
    float I_error;
    float last_error;
    float output;
}PID;
/**
 * 位置式pid
 * @param pid PID参数结构体
 * @param P
 * @param I
 * @param D
 * @param target 目标值
 * @param I_limit I误差积分限幅
 * @param output_limit 输出限幅
 * @param current_value 当前值
 * @return
 */
float pidAlgorithm(PID* pid,float P,float I,float D,float target, float I_limit,float output_limit,float current_value);
#define _constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))

#endif //FOC3_PID_H
